namespace FastNetCore.Core.Response;

/// <summary>
/// 接口返回结果
/// </summary>
public class ResponseResult
{
    /// <summary>
    /// 返回结果代码
    /// </summary>
    public int Code { get; set; }
    
    /// <summary>
    /// 接口调用是否成功
    /// </summary>
    public bool IsSuccess { get;set; }
    
    /// <summary>
    /// 接口返回信息
    /// </summary>
    public string Message { get;set;}
    
    /// <summary>
    /// 接口返回数据
    /// </summary>
    public Object? Data { get;set; }

    public ResponseResult()
    {
        this.Code = ResponseCode.SUCCESS_CODE;
        this.Message=string.Empty;
        this.IsSuccess=true;
        this.Data=null;
    }

    public ResponseResult(int code, string message)
        :this()
    {
        this.Code = code;
        this.Message = message;
    }

    public ResponseResult(int code, bool success, string message, Object data)
    {
        this.Code = code;
        this.IsSuccess = success;
        this.Message = message;
        this.Data = data;
    }

    public static SuccessResponseResult Success()
    {
        return new SuccessResponseResult();
    }

    public static SuccessResponseResult Success(object data)
    {
        return new SuccessResponseResult(data);
    }

    public static SuccessResponseResult Success(int code, string message, Object data)
    {
        return new SuccessResponseResult(code, message, data);
    }

    public static FailResponseResult Fail()
    {
        return new FailResponseResult();
    }

    public static FailResponseResult Fail(int code, string message)
    {
        return new FailResponseResult(code, message);
    }

    public static FailResponseResult Fail(int code, string message, Object data)
    {
        return new FailResponseResult(code, message, data);
    }
    
    
}